package com.woniu.microcommunityserver.advert.mapper;

import com.woniu.microcommunityserver.advert.entity.AdvertSlideshowInfoEntity;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AdvertSlideshowInfoMapper {
    /**
     * 查询所有轮播图
     * @return
     */
    @Select("select id,slideshow_storage_address,slideshow_state from advert_slideshow_info")
    @ResultMap(value = "advertSlideshowInfoMap")
    List<AdvertSlideshowInfoEntity> find();

    /**
     * 根据状态查询
     * @param slideshowState
     * @return
     */
    @Select("select id,slideshow_storage_address,slideshow_state from advert_slideshow_info " +
            "where slideshow_state=#{slideshowState}")
    @ResultMap(value = "advertSlideshowInfoMap")
    List<AdvertSlideshowInfoEntity> findByState(Integer slideshowState);
    /**
     * 通过id修改轮播图状态
     * @param slideshowState
     * @param id
     * @return
     */
    @Update("update advert_slideshow_info set slideshow_state=#{slideshowState} where id=#{id}")
    boolean updateStateById(Integer slideshowState,Long id);

    /**
     * 新增轮播图
     * @return
     */
    @Insert("insert into advert_slideshow_info(slideshow_description,slideshow_storage_address,slideshow_state) " +
            "values(#{slideshowDescription},#{slideshowStorageAddress},#{slideshowState})")
    boolean insertAdvert(AdvertSlideshowInfoEntity advertSlideshowInfoEntity);

}